package models.common;

import ext.jpa.UUIDModel;
import facade.AppContext;
import models.base.AdminUser;
import models.base.Corp;
import models.constants.DeletedStatus;

import javax.persistence.*;
import java.util.Date;

@MappedSuperclass
public class BaseModel extends UUIDModel {

    /**
     * 所属公司
     */
    @ManyToOne
    @JoinColumn(name = "corp_id")
    public Corp corp = AppContext.currentCorp();

    /**
     * 创建时间.
     */
    @Column(name = "created_at")
    public Date createdAt = new Date();
    /**
     * 创建人.
     */
    @ManyToOne
    @JoinColumn(name = "create_user_id")
    public AdminUser createUser = AppContext.currentUser();

    /**
     * 更新时间.
     */
    @Column(name = "modify_at")
    public Date modifyAt;
    /**
     * 更新人.
     */
    @ManyToOne
    @JoinColumn(name = "modify_user_id")
    public AdminUser modifyUser;

    /**
     * 逻辑删除,0:未删除，1:已删除
     */
    @Enumerated(EnumType.ORDINAL)
    @Column(name = "deleted")
    public DeletedStatus deleted = DeletedStatus.UN_DELETED;

}
